package com.dylan.channel.v11;

public abstract class MultiTreadEventExecutorGroup implements EventExecutorGroup {
    EventExecutor[] executors;

    volatile  int  index;

    public MultiTreadEventExecutorGroup(int treads) {
        executors=new EventExecutor[treads];
        for (int i = 0; i < treads; i++) {
            executors[i]=newChild();
        }
    }

    @Override
    public EventExecutor next() {
        int id=index%executors.length;
        index++;
        return executors[id];
    }

    @Override
    public void execute(Runnable command) {
        next().execute(command);
    }

    protected abstract EventExecutor newChild() ;

    @Override
    public void shutdownGraceFull() {

    }
}
